//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "fn_checkUnitState.sqf"
#include <btc_macros.h>
TRACE_1("Start",_this);


	_unit = objNull;
	if (count _this == 0) then
	{
		_men = nearestObjects [vehicle player, ["Man"], 3];
		if (count _men > 1) then {_unit = _men select 1;};
	} else {_unit = player;};
	_var = _unit getVariable "BTC_r_status";
	_is_bleed = _var select 0;
	_bleeding = _var select 1;
	_mor      = _var select 2;
	_epi      = _var select 3;
	_med      = _var select 4;
	_text = format ["%1 ",name _unit];
	if (_is_bleed == 0) then {_text = _text + "is not bleeding. ";} else {_text = _text + "is bleeding and ";};
	if (_mor == 0) then {_text = _text + "He is not in pain. ";} else {_text = _text + "He is in pain and needs morphine. ";};
	if (_epi == 0) then {} else {_text = _text + "He needs epinephrine. ";};
	if (_med == 0) then {} else {_text = _text + "He needs a medikit. ";};
	hint _text;
	if (_is_bleed > 0 || _bleeding > 0 || _mor != 0 || _epi != 0 || _med != 0) then
	{
		BTC_r_unit_dlg = _unit;
		disableSerialization;
		_dlg = createDialog "BTC_state_dialog";
		_ui = uiNamespace getVariable "BTC_r_dialog";
		if (_is_bleed == 0) then {(_ui displayCtrl 91) ctrlShow false;};
		if (_bleeding == 0 || _is_bleed != 0) then {(_ui displayCtrl 96) ctrlShow false;};
		if (_mor == 0) then {(_ui displayCtrl 92) ctrlShow false;};
		if (_epi == 0) then {(_ui displayCtrl 93) ctrlShow false;};		
		if (format ["%1",BTC_r_unit_dlg getVariable "BTC_need_revive"] != "1") then {(_ui displayCtrl 94) ctrlShow false;};
		if (_med == 0 || _epi != 0 || _mor != 0 || _is_bleed != 0 || _bleeding != 0) then {(_ui displayCtrl 95) ctrlShow false;};
		waitUntil {!Alive player || !dialog || !Alive _unit || isNull _unit};
		closeDialog 0;
		BTC_r_unit_dlg = objNull;
	};
